using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace Colorprj
{
    public partial class frmrptProductWisePurchase : Form
    {
        public frmrptProductWisePurchase()
        {
            InitializeComponent();
        }

        private void btnShow_Click(object sender, EventArgs e)
        {
            showReport(dtpDateFrom.Value, dtpdateto.Value);
        }
        private void showReport(DateTime fromDate, DateTime todate)
        {

            ReportDocument cryRpt = new Report.rptProductWisePurchase();

            ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();

            ParameterField paramField2 = new ParameterField();
            //ParameterFields paramFields2 = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue2 = new ParameterDiscreteValue();


            ParameterField paramField3 = new ParameterField();
            //ParameterFields paramFields3 = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue3 = new ParameterDiscreteValue();
            ParameterField paramField4 = new ParameterField();
            ParameterDiscreteValue paramDiscreteValue4 = new ParameterDiscreteValue();


            //Set instances for input parameter 1 -  @vDepartment
            paramField2.Name = "fromDate";

            //Below variable can be set to any data present in SalseData table, Department column
            paramDiscreteValue2.Value = fromDate;
            paramField2.CurrentValues.Add(paramDiscreteValue2);
            //Add the paramField to paramFields
            paramFields.Add(paramField2);

            //Set instances for input parameter 1 -  @vDepartment
            paramField3.Name = "toDate";

            //Below variable can be set to any data present in SalseData table, Department column
            paramDiscreteValue3.Value = todate;
            paramField3.CurrentValues.Add(paramDiscreteValue3);
            //Add the paramField to paramFields
            paramFields.Add(paramField3);

            paramField4.Name = "cName";

            //Below variable can be set to any data present in SalseData table, Department column
            paramDiscreteValue4.Value = Globalclass.CompanyName;
            paramField4.CurrentValues.Add(paramDiscreteValue4);
            //Add the paramField to paramFields
            paramFields.Add(paramField4);



            crystalReportViewer1.ParameterFieldInfo = paramFields;
            cryRpt.DataSourceConnections[0].SetConnection(Globalclass.DsnName, Globalclass.DbName, "atul", "vikas");
            cryRpt.SetDatabaseLogon("atul", "vikas", Globalclass.DsnName, Globalclass.DbName, false);
            crystalReportViewer1.ReportSource = cryRpt;

        }


        private void dtpdateto_ValueChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void dtpDateFrom_ValueChanged(object sender, EventArgs e)
        {

        }

        private void crystalReportViewer1_Load(object sender, EventArgs e)
        {

        }
    }
}